package threads.volatiletest;

import java.util.concurrent.atomic.AtomicInteger;

public class SerialNumberGenerator
{

//	private static int serialNumber = 0;
	
//	public synchronized static int nextSerialNumber()
//	{
//		return serialNumber++;
//	}
	
	private static AtomicInteger serialNumber = new AtomicInteger(0);
	
	
	
	public  static int nextSerialNumber()
	{
		System.out.println("serialNumber=" + serialNumber + " " + (Thread.currentThread().getName()));
		return serialNumber.incrementAndGet();
	}
	
}
